﻿@using CubicFWNet.Data.ViewModal
@model CubicFWNet.Data.Models.Equipment
@{
    //ViewBag.Title = "价格核算";
    //var operationName = ViewBag.OperationName;
    //var operationTime = ViewBag.OperationTime;
    var sign = ViewBag.Sign;
}
<section class="content-header">
    <h1>
        类别维护
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("TechType", "FinanceCost")">类别维护</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                <form class="form-horizontal" id="frmedit" action="@Url.Action("AddOrUpdateEquipment", "FinanceCost")" method="post">
                    <div class="box-body">
                        <input type="hidden" id="Id" name="Id" value="@Model.Id" />
                        <input type="hidden" id="sign" name="sign" value="@sign" />
                        <div id="json-content">
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">设备名称</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control" id="EquipmentName" name="EquipmentName" value="@Model.EquipmentName" data-des="设备名称" required  readonly="readonly"/>
                                </div>
                            </div>
                            @*<div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">检验人工-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="TestWork" name="TestWork" value="@Model.TestWork" data-des="检验人工-元/分钟" />
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label class="col-sm-3 control-label">操作人工-元/分钟</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control okeydown" id="OperateWork" name="OperateWork" value="@Model.OperateWork" data-des="操作人工-元/分钟" />
                                    </div>
                                </div>*@
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">管理费用-元/分钟</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="ManageWork" name="ManageWork" value="@Model.ManageWork" data-des="管理费用-元/分钟" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">设备 工具 折旧-元/分钟</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="ToolWork" name="ToolWork" value="@Model.ToolWork" data-des="设备 工具 折旧-元/分钟" />
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="col-sm-3 control-label">销售费用-元/分钟</label>
                                <div class="col-sm-9">
                                    <input type="text" class="form-control okeydown" id="SalesWork" name="SalesWork" value="@Model.SalesWork" data-des="销售费用-元/分钟" />
                                </div>
                            </div>
                            <div class="form-group col-md-12" style="height: 1px;"></div>
                        </div>
                    </div>
                    <div class="box-footer" style="width: 80%; margin-left: 20px;">
                        <a role="button" href="javascript:void(0)" class="btn btn-primary submitbtn" onclick="formsubmit(1)">保存</a>
                        <a role="button" href="@Url.Action("TechType", "FinanceCost")" class=" btn btn-primary submitbtn">返回</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

<style>
    .has-error {
        border-color: #dd4b39;
        box-shadow: none;
    }
</style>


@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#frmedit").validate({
                submitHandler: function (form) {
                    var postData = $(form).formSerialize();
                    $.submitForm({
                        url: $(form).attr("action"),
                        param: postData,
                        success: function () {
                            $.modalAlert("操作成功", "success");
                            window.location.href = '@Url.Action("TechType", "FinanceCost")';
                        }
                    });
                }
            });
        });

        function formsubmit(t) {
            if (getParam()) {
                $("#frmedit").submit();
            }
        }

        $(".okeydown").on("keyup", function () {
            var value = $(this).val();
            if (isNaN(value) || value == "" || value == "Infinity" || value == "NaN") {
                $(this).addClass("has-error");
            } else {
                $(this).removeClass("has-error");
            }
        });


        $(".okeydown").on("keydown", function () {
            var k = event.keyCode;
            if ((k <= 57 && k >= 48) || (k <= 105 && k >= 96) || (k == 8) || (k == 110) || (k == 190)) {
                return true;
            } else {
                return false;
            }
        });

        //$(".productinfo").click(function () {
        //    var id = $(this).data('id');
        //    var options = {
        //        id: null,
        //        title: '产品信息',
        //        width: "100%",
        //        height: "100%",
        //        url: "../Product/Info?PID=" + id,
        //        shade: 0.3,
        //        btn: ['返回'],
        //        btnclass: ['btn btn-danger'],
        //        callBack: null
        //    }
        //    $.modalOpen(options);
        //});
        //$(".technologyinfo").click(function () {
        //    var id = $(this).data('id');
        //    var options = {
        //        id: null,
        //        title: '产品信息',
        //        width: "100%",
        //        height: "100%",
        //        url: "../Technology/TechnologyInfo?tId=" + id,
        //        shade: 0.3,
        //        btn: ['返回'],
        //        btnclass: ['btn btn-danger'],
        //        callBack: null
        //    }
        //    $.modalOpen(options);
        //});


        function getParam() {
            var flag = true;
            $("#json-content").find('.form-control').each(function (r) {
                var $this = $(this);
                var v = $this.val();
                var des = $this.attr("data-des");
                if (v == "") {
                    flag = false;
                    $.modalAlert(des + "不可为空", "warning");
                    return false;
                }
                if (des != "设备名称" && isNaN(v)) {
                    flag = false;
                    $.modalAlert(des + "格式错误", "warning");
                    return false;
                }
            });
            return flag;
        }
    </script>
}